export const nuxtRequest = <T>(options:{
    url:string,
    method?:string,
    params?:Record<string,any>
}): Promise<T> =>{
    const {
        url,
        method = 'get',
        params = {}
    } = options
    const reqUrl = Object.entries(params).length ? url + joinParams(params) : url
    return $fetch(reqUrl).then((data)=>{
        // @ts-ignore
        return data.data as T
    })
}
// 拼接url参数
function joinParams(params:Record<string,any>):string{
    return '?' + Object.entries(params).map(item=>{
        return item.join('=')
    }).join('&')
}